package com.huayi.server.Controller;


import com.huayi.server.Dao.AdminDao;
import com.huayi.server.Entity.AdminEntity;
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

/**
 * Created by mac on 2017/8/21.
 */

@Controller
public class TestController {

    private Logger logger = LoggerFactory.getLogger(TestController.class);


    @Autowired
    AdminDao adminDao;

    public TestController() {
        logger.info("test");
    }

    @RequestMapping("/test")
    public String test(){
        AdminEntity adminEntity =  adminDao.getAdminInfo("admin");
        logger.info("admin:"+adminEntity.toString());
        return "test";
    }

    @RequestMapping("/mytest/{username}")
    public String testone(@PathVariable String username){
        AdminEntity adminEntity = adminDao.getAdminInfo(username);
        if (adminEntity==null){
            logger.info("admin is null");
        }else {
            logger.info("admin:"+adminEntity.toString());
        }
        return "test";
    }


}
